package com.dongdongshop.service.impl;

import com.dongdongshop.bs.BsService;
import com.dongdongshop.mapper.TbBrandMapper;
import com.dongdongshop.pojo.TbBrand;
import com.dongdongshop.pojo.TbBrandExample;
import com.dongdongshop.service.BrandService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@DubboService
@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private TbBrandMapper tbBrandMapper;
    @Autowired
    private BsService bsService;
    @Override
    public List<TbBrand> listBrands() {
        bsService.test(1);
        return tbBrandMapper.selectByExample(null);
    }

    @Override
    public void saveBrand(TbBrand brand) {
        tbBrandMapper.insertSelective(brand);
    }

    @Override
    public void updateBrand(TbBrand brand) {
        tbBrandMapper.updateByPrimaryKeySelective(brand);
    }

    @Override
    public TbBrand selectBrandById(Long id) {
        return tbBrandMapper.selectByPrimaryKey(id);
    }

    @Override
    public void delBrand(List<Long> ids) {
        TbBrandExample tbBrandExample = new TbBrandExample();
        TbBrandExample.Criteria criteria = tbBrandExample.createCriteria();
        criteria.andIdIn(ids);
        tbBrandMapper.deleteByExample(tbBrandExample);
    }
}
